<?php
header( "Content-Type:text/html; charset=utf-8" );
require_once("config.inc.php");
require_once("weibo.class.php");
require_once("db.class.php");
ignore_user_abort();
set_time_limit(0);
$wb = new weibo(APP_KEY, SECRET_KEY);
$wb->setUser( USER_NAME , USER_PASS );
$db = new db($site_Db);
//取出未处理的请求
$commentList = $db->fetchrows("SELECT * FROM comment WHERE deal=0");
if(!empty($commentList)) {
	foreach( $commentList as $comment )
	{
		$id = $comment['id'];
		$tid = $comment['tid'];
		$data = $comment['comment'];
			
		//发送评论	
		$comment_return = $wb->send_comment( $tid , $data );
		//print_r($comment_return);
		//if (empty($comment_return['id'])){
		//	echo "Send comment error.\n";
		//} else {
			if($db->query("UPDATE comment SET deal=1 WHERE id={$id}"))
				echo "Send a comment.\n";
		//}
	}
} else {
	echo "No comment queue.\n";
}

$db->close();

?>